<?php
/**
 * 获取入院记录
 * Created by PhpStorm.
 * User: zhang-hong
 * Date: 2017/3/8
 * Time: 11:26
 */
class GetruyuanjiludataController extends Yaf_Controller_Abstract
{

    function IndexAction()
    {
        $request = $this->getRequest();
        $zhuyuan_id = $request->getPost("zhuyuan_id",0);
        $yiyuan_id = $request->getPost("yiyuan_id",0);
        //$zhuyuan_id = strip_tags($_REQUEST['zhuyuan_id']);
        //$yiyuan_id = strip_tags($_REQUEST['yiyuan_id']);
        $zhuyuanbingshiModel = new ZhuyuanBingshiModel();
        if(!ctype_digit("$yiyuan_id"))
        {
            Utility::apiJsonError(20027, '医院ID必须是整型');
        }
        // 病史
        $zhuyuan_bingshi = $zhuyuanbingshiModel->GetBingShi($zhuyuan_id,$yiyuan_id);
        //print_r($zhuyuan_bingshi);exit;
        if(empty($zhuyuan_bingshi) ||(is_array($zhuyuan_bingshi)&&count($zhuyuan_bingshi)==0))
        {
            $data["state"] = "0";
            //Utility::apiJsonError(20023, '参数错误');
        }
        else
        {
            $data["state"] = "1";
            $ruyuan_jilu = array();
            foreach ($zhuyuan_bingshi as $key => $one_bingshi)
            {
                $one_bingshi =  strip_tags($one_bingshi);
                $one_bingshi =  trim($one_bingshi);
                $one_bingshi =  str_replace("&nbsp;", " ", $one_bingshi);
                $ruyuan_jilu[$key] =  $one_bingshi;
            }

            // 体格检查
            $zhuyuan_ruyuantigejiancha =$zhuyuanbingshiModel->GetTigeJianChan($zhuyuan_id,$yiyuan_id);
            if(!empty($zhuyuan_ruyuantigejiancha))
            {
                foreach ($zhuyuan_ruyuantigejiancha as $key => $one_jiancha)
                {
                    $one_jiancha =  strip_tags($one_jiancha);
                    $one_jiancha =  trim($one_jiancha);
                    $one_jiancha =  str_replace("&nbsp;", " ", $one_jiancha);
                    $ruyuan_jilu[$key] =  $one_jiancha;
                }
            }
            $data["result"] = $ruyuan_jilu;
        }
        $data["msg"] = "";
        $data["error"] = 200;
        Utility::apiJsonResultExtends($data);
        //$compression_http_data = $_REQUEST["compression_http_data"];
        //Utility::apiJsonResult($data,"",$compression_http_data);
    }
}